<?php
	/**
	 * 
	 * Enter description here ...
	 * @author Jeferson
	 *
	 */
	class Application_Model_DbTable_Generica extends Zend_Db_Table_Abstract
	{
		/*
		 * 
		 */
		protected $_name = "agenda.tb_generica";
		
		/**
		 * 
		 * Enter description here ...
		 * @param unknown_type $intCoGenerica
		 */
		public function getGenerica( $intCoGenerica )
		{
			$intCoGenerica	= (int)$intCoGenerica;
			$row			= $this->fetchRow( "co_generica = " . $intCoGenerica );
			if ( ! $row ) throw new Exception( "Nenhum resultado encontrado " . $intCoGenerica );
			return $row->toArray();
		}
		
		/**
		 * 
		 * Enter description here ...
		 * @param unknown_type $artist
		 * @param unknown_type $title
		 */
		public function addGenerica( $intCoTipoGenerica , $strDsGenerica , $strDtInsercao , $strStAtivo )
		{
			$arrData = array
			(
  				"co_tipo_generica"	=> $intCoTipoGenerica ,
  				"ds_generica"		=> $strDsGenerica ,
  				"dt_insercao"		=> $strDtInsercao , 
  				"st_ativo"			=> $strStAtivo
			);
			$this->insert( $arrData );
		}
		
		/**
		 * 
		 * Enter description here ...
		 * @param unknown_type $id
		 * @param unknown_type $artist
		 * @param unknown_type $title
		 */
		public function updateGenerica( $intCoGenerica , $intCoTipoGenerica , $strDsGenerica , $strDtInsercao , $strStAtivo )
		{
			$arrData = array
			(
  				"co_tipo_generica"	=> $intCoTipoGenerica ,
  				"ds_generica"		=> $strDsGenerica ,
  				"dt_insercao"		=> $strDtInsercao , 
  				"st_ativo"			=> $strStAtivo
			);
			$this->update( $arrData , "co_generica = " . (int)$intCoGenerica );
		}
		
		/**
		 * 
		 * Enter description here ...
		 * @param unknown_type $id
		 */
		public function deleteGenerica( $intCoGenerica )
		{
			$this->delete( "co_generica =" . (int)$intCoGenerica );
		}
		
		public function getGenericaByTipo( $intCoTipoGenerica )
		{
			$intCoTipoGenerica	= (int)$intCoTipoGenerica;
			$row				= $this->fetchAll( "co_tipo_generica = " . $intCoTipoGenerica );
			if ( ! $row ) throw new Exception( "Nenhum resultado encontrado " . $intCoTipoGenerica );
			return $row->toArray();
		}
	}